﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spring.Context.Support;
using Project.Manager;
using System.Web.UI;
using Project.Common;

/// <summary>
/// 后台管理用户 基类
/// </summary>
public class AdminPage : LoginPage
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        if (currentUser == null ||( currentUser.UserType != ((int)EnumUserType.受理中心).ToString() && currentUser.UserType != ((int)EnumUserType.管理员).ToString()))
            {
                // 用Session保存需要登录才能访问的页面，以便在登录后可以重定向到该页面
                if (Request.Url != null)
                {
                    Session["UrlLogonBefore"] = null;
                    Session["UrlLogonBefore"] = Request.Url.ToString();
                }
                ManagerFactory.UserManagerManager.SignOut();
                //Response.Redirect("~/Home/Login.aspx?errmsg=权限不足");
                Response.Redirect("~/Home/Login.aspx?errmsg=用户名或者密码错误");
            }
    }
    //int CheckUser()
    //{
    //    List<int> a = new List<int>();
    //    a.Add((int)EnumUserType.受理中心);
    //    a.Add((int)EnumUserType.管理员);
    //    for (int i = 0; i < a.Count; i++)
    //    {
    //        if (currentUser.UserType == a[i].ToString())
    //            return 1;
    //    }
    //}

}
